using System.Text;

namespace NFreeMarker.Core
{
    public sealed class RecoveryBlock : TemplateElement // NOTE: Was internal
    {
        internal RecoveryBlock(TemplateElement block)
        {
            NestedBlock = block;
        }

        internal override void Accept(Environment env)
        {
            if (NestedBlock != null)
            {
                env.Visit(NestedBlock);
            }
        }

        public override string GetCanonicalForm()
        {
            var buf = new StringBuilder("<#recover>");
            if (NestedBlock != null)
            {
                buf.Append(NestedBlock.GetCanonicalForm());
            }
            buf.Append("/#recover");
            return buf.ToString();
        }

        public override string GetDescription()
        {
            return "recover block";
        }
    }
}